<template>
	<!-- 服务首页 -->
	<view class="service" >
		<!-- u-navbar用于app端适配 -->
		<u-navbar :is-back="false" title="" height="0"></u-navbar>
		<view class="title">服务</view>
		<!-- banner图 -->
		<!-- <view class="banner" @click="goShop"> -->
		<view class="banner">
			<image src="../../../static/img/p_banner-2.jpg">
		</view>
		<u-gap height="16" margin-top="30" bg-color="#f3f3f3"></u-gap>
		<!-- 登录提示（未登录显示） -->
		<view class="login-tip" v-if="!isLogin">
			<!-- 头像 -->
			<view class="avatar">
				<image src="../../../static/image/login_head.png">
			</view>
			<view class="tip-text">立即登录，即享服务顾问一对一服务</view>
			<view class="btn-wrapper">
				<u-button
					type="warning"
					hover-class="none"
					shape="circle"
					:custom-style="{backgroundColor: '#d6b181'}"
					@click="goLogin"
				>登录</u-button>
			</view>
		 </view>
		 <!-- 指定服务（需登录） -->
		<view class="choose-service" v-if="isLogin">
			<view class="wrapper">
				<view class="avatar">
					<image src="../../../static/image/login_head.png">
				</view>
				<view class="text-wrapper" @click="goKefu">
					<view class="text">服务顾问尊享服务</view>
					<view class="subtext">指定服务顾问，立享贴身服务</view>
				</view>				
			</view>
			<!-- 指定按钮 -->
			<!-- <view class="choose-btn">
				<u-button
					type="warning"
					hover-class="none"
					shape="circle"
					:custom-style="chooseBtnStyle"
					@click="goZhiding"
				>立即指定</u-button>
			</view> -->
		</view>
		<u-gap height="16" bg-color="#f3f3f3"></u-gap>
		<!-- 认证服务 -->
		<view class="serive-container">
			<view class="serive-container-title">
				<view>认证服务</view>
				<view class="more-btn" @click="goProduct">更多服务</view>
			</view>
			<view class="service-list">
				<view class="service-item" :class="{active: isAuth}" @click="gotAuthen">
					<view class="item-img">
						<u-icon name="account" color="#999" size="44"></u-icon>
						<view class="label">{{isAuth ? '已认证' : '未认证'}}</view>
					</view>
					<view
						class="text-wrapper"
						:class="{textActive: isAuth}"
					>
						<view class="name">实名认证</view>
						<view class="desc">解锁私募资管列表</view>						
					</view>
				</view>
				<view class="service-item" :class="{active: isLev}" @click="gotRisk">
					<view class="item-img">
						<u-icon name="integral" color="#999" size="44"></u-icon>
						<view class="label">{{isLev ? '已测评' : '未测评'}}</view>
					</view>
					<view class="text-wrapper" :class="{textActive: isLev}">
						<view class="name">风险测评</view>
						<view class="desc">测试风险承受能力</view>
					</view>
				</view>
				<!-- <view class="service-item"  @click="gotOpen">
					<view class="item-img">
						<u-icon name="calendar" color="#999" size="44"></u-icon>
						<view class="label">未开通</view>
					</view>
					<view class="text-wrapper">
						<view class="name">开通基金账户</view>
						<view class="desc">方便您购买优质产品</view>
					</view>
				</view> -->
				<!-- <view  class="service-item" @click="goQualified">
					<view class="item-img">
						<u-icon name="order" color="#999" size="44"></u-icon>
						<view class="label">去认证</view>
					</view>
					<view class="text-wrapper">
						<view class="name">合格投资者认证</view>
						<view class="desc">认证合格投资者</view>
					</view>
				</view> -->
			</view>
		</view>
		<!-- <u-gap height="16" bg-color="#f3f3f3"></u-gap> -->
		<!-- 专属资产规划服务 -->
		<!-- <view class="serive-container">
			<view class="serive-container-title">专属资产规划服务</view>
			<view class="service-list">
				<view class="service-item"  @click="goInvite">
					<view class="item-img">
						<u-icon name="email" color="#999" size="44"></u-icon>
					</view>
					<view class="text-wrapper">
						<view class="name">投资建议书</view>
						<view class="desc">特邀客户活动</view>
					</view>
				</view>
				<view class="service-item"  @click="goVideo">
					<view class="item-img">
						<u-icon name="play-circle" color="#999" size="44"></u-icon>
					</view>
					<view class="text-wrapper">
						<view class="name">视频专区</view>
						<view class="desc">视频直播与分享</view>
					</view>
				</view>
				<view class="service-item" @click="goActivity">
					<view class="item-img">
						<u-icon name="gift" color="#999" size="44"></u-icon>
					</view>
					<view class="text-wrapper">
						<view class="name">活动专区</view>
						<view class="desc">特邀活动客户</view>
					</view>
				</view>
			</view>
		</view> -->
		<!-- 占位 -->
		<u-gap height="120"></u-gap>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				current: 0,
				isLogin: false,	// 是否登录
				isAuth: false, // 是否实名
				isLev: false, // 是否测评风险
				chooseBtnStyle: { // 指定按钮样式
					width:'174rpx',
					height:'58rpx',
					fontSize: '26rpx',
					whiteSpace: 'nowrap',
					backgroundColor: '#d6b181',
				}
			}
		},
		methods: {
			// 客服
			goKefu(){
				var that = this;
				that.$u.post('https://vs1.0793ct.com//api/my/service',{}).then(res=>{
					// console.log(res)
					this.serveUrl = res.data
					// 获取后跳转
					//#ifdef H5
					window.location.href = this.serveUrl
					//#endif
					
					//#ifdef APP-PLUS
					plus.runtime.openWeb(this.serveUrl)
					//#endif
				})
				
			},
			// 点击头部图片跳转到商城页面
			goShop(){
				// uni.navigateTo({
				// 	url:''
				// })
				uni.showToast({
				    title: '商城暂无开放',
				    duration: 2000,
					icon:'none',
				});
			},
			
			goProduct(){
				uni.navigateTo({
					url:'/pages/components/service/more_services'
				})
			},
			// 跳转 实名认证 页面
			gotAuthen(){
				// 已实名不执行操作
				if (this.isAuth) {
					return
				}
				uni.navigateTo({
					url:'/pages/components/service/photo_details'
				});
			},
			gotOpen(){
				// uni.navigateTo({
				// 	url:'/pages/components/service/open_users'
				// });	
				this.$u.toast('暂无开通基金账户暂')
			},
			gotRisk(){
				// if(this.isLev){
				// 	return
				// }
				uni.navigateTo({
					url:'/pages/components/service/risk_assessment'
				});	
			},
			goQualified(){
				// uni.navigateTo({
				// 	url:'/pages/components/service/qualified_investors'
				// });	
				this.$u.toast('暂无合格投资者认证')
			},
			goInvite(){
				// console.log('touji')
				uni.navigateTo({
					url: '/pages/components/service/investment_advice'
				});
			},
			goVideo(){
				uni.showToast({
				    title: '暂无开放视频区',
					 duration: 2000,
					 icon:'none',
				});	
			},
			goActivity(){
				uni.navigateTo({
					url:'/pages/components/service/activety'
				});	
			},
			// 首次登录
			goLogin(){
				uni.navigateTo({
					url: '/pages/components/login/login'
				})
			},
			goZhiding(){
				uni.showToast({
				    title: '暂无指定服务',
					 duration: 2000,
					 icon:'none',
				});
			},
		},
		onShow(option) {
			// 获取token判断显示头部状态
			this.token = uni.getStorageSync('token')
			// console.log("有token:"+uni.getStorageSync('token'))
			if(this.token != ''){
				this.isLogin = true;
			}else{
				this.isLogin = false;
			}
			
			// 获取实名认证的状态
			const auth = uni.getStorageSync('auth_status')
			if (auth == 0) {
				this.isAuth = false
			} else if (auth == 1) {
				this.isAuth = true;
			}
			
			if (this.isLogin) { // 登录再请求
				// 获取测评结果
				this.$u.post('https://vs1.0793ct.com//api/user/assessmentResult',{}).then(res => {
					// console.log(res)
					this.lev = res.data.result
					// console.log(this.lev)
					if(this.lev === ''){
						this.isLev = false
					} else {
						this.isLev = true
					}
				
				}).catch(err => {
					// console.log(err)
				})					
			}
				
		},
		onLoad:function(option){
			
		},
		
		
	}
</script>

<style lang="scss" scoped>
	// 服务首页
	.service {
		.title {
			padding: 20rpx 30rpx 0;
			font-size: 50rpx;
			font-weight: bold;
		}
		// banner图
		.banner {
			display: flex;
			justify-content: center;
			margin-top: 30rpx;
			image {
				width: 700rpx;
				height: 200rpx;
			}
		}
		// 登录提示（未登录显示）
		.login-tip {
			box-sizing: border-box;
			height: 350rpx;
			// 头像
			.avatar {
				display: flex;
				justify-content: center;
				margin-top: 60rpx;
				image {
					width: 80rpx;
					height: 80rpx;
					border-radius: 50%;
				}
			}
			.tip-text {
				margin-top: 30rpx;
				font-size: 30rpx;
				color: #999;
				text-align: center;
			}
			.btn-wrapper {
				margin-top: 30rpx;
				padding: 0 80rpx;
			}
		}
		// 指定服务（需登录）
		.choose-service {
			display: flex;
			justify-content: space-between;
			align-items: center;
			height: 192rpx;
			padding: 0 30rpx;
			.wrapper {
				display: flex;
				align-items: center;
				.avatar {
					image {
						width: 90rpx;
						height: 90rpx;
						border-radius: 50%;
					}
				}
				.text-wrapper {
					display: flex;
					flex-direction: column;
					margin-left: 20rpx;
					.text {
						font-size: 32rpx;
						font-weight: 600;
						color: #999;
					}
					.subtext {
						font-size: 28rpx;
						color: #999;
					}
				}
			}
			// 指定按钮
			.choose-btn {}
		}
	}
	// 服务
	.serive-container {
		padding: 40rpx 30rpx 0;
		.serive-container-title {
			display: flex;
			justify-content: space-between;
			font-size: 40rpx;
			font-weight: 600;
			.more-btn {
				display: flex;
				justify-content: center;
				align-items: center;
				width: 140rpx;
				height: 48rpx;
				font-size: 26rpx;
				font-weight: 500;
				color: #999;
				border: 2rpx solid #999;
				border-radius: 24rpx;
			}
		}
		.service-list {
			display: flex;
			flex-wrap: wrap;
			padding: 30rpx 0;
			.service-item {
				flex: 0 0 50%;
				display: flex;
				align-items: center;
				height: 160rpx;
				&.active {
					opacity: 0.4;
				}
				.item-img {
					position: relative;
					display: flex;
					justify-content: center;
					align-items: center;
					width: 70rpx;
					height: 70rpx;
					border: 2rpx solid #999;
					border-radius: 50%;
					.label {
						position: absolute;
						bottom: -24rpx;
						display: flex;
						justify-content: center;
						align-items: center;
						width: 100rpx;
						height: 36rpx;
						font-size: 24rpx;
						background-color: #f3f3f3;
						border-radius: 18rpx;
						box-shadow: 0 4rpx 0 0 #eee;
					}
				}
				.text-wrapper {
					display: flex;
					flex-direction: column;
					margin-left: 20rpx;
					color: #000;
					.name {
						font-size: 30rpx;
						font-weight: 600;
					}
					.desc {
						font-size: 26rpx;
					}
				}
			}
		}
	}
</style>
